package fr.antonyweb.jfx.easyconduite;

import javafx.animation.Timeline;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.stage.Stage;
import fr.antonyweb.jfx.easyconduite.objects.Chrono;

public class MainApp extends Application {

	@Override
	public void start(Stage stage) throws Exception {
		
		
		
		final FXMLLoader loader = new FXMLLoader(getClass().getResource(
				"/fxml/easyconduite.fxml"));

		Parent root = loader.load();
		
		FXMLController controller = loader.getController();
		controller.setStage(stage);
		
		Scene scene = new Scene(root);
		scene.getStylesheets().add("/styles/Styles.css");

		Label ltimer = (Label) scene.lookup("#timer");
		Timeline timeline = Chrono.getTimeline(ltimer);
		controller.setTimeline(timeline);
		
		AudioTable audioTable = AudioTable.getInstance();
		audioTable.setScene(scene);

		stage.setTitle("EasyConduite 0.1");
		stage.setScene(scene);
		stage.show();

	}

	/**
	 * The main() method is ignored in correctly deployed JavaFX application.
	 * main() serves only as fallback in case the application can not be
	 * launched through deployment artifacts, e.g., in IDEs with limited FX
	 * support. NetBeans ignores main().
	 *
	 * @param args
	 *            the command line arguments
	 */
	public static void main(String[] args) {
		launch(args);
	}

}
